<?php
/**
 * ��ݷ������
 *
 * @author Chen HuiYun <11chenhuiyun@gmail.com>
 * @copyright Copyright &copy; 2012-2020 MyyTaijii Software LLC
 */

/**
 * @author Chen HuiYun
 */
class BDataService implements IObjectType, IModule, ICheckType
{
	/**
	 * TODO ȥ��
	 */
	private $con = null;
	public function __construct($con)
	{
		$this->con = $con;
	}
	
	public function getConnection()
	{
		return $this->con;
	}
	
	public function setConnection($con)
	{
		$this->con = $con;
	}
	
	/**
	 * Enter description here ...
	 * @param BCommonBean $cb
	 * @return array
	 */
	public function getArray($cb)
	{
		$arr = array();
		$cbRowNum = $cb->getRowNum();
		if ($cb || ($cbRowNum > 0)) {
			$cbColNum = $cb->getColNum();
			for ($i = 0; $i < $cbRowNum; $i++) {
				for ($j = 0; $j < $cbColNum; $j++) {
					$arr[$i][$j] = $cb->getCellValue($i, $j);
				}
			}
		}
		return $arr;
	}
	
	public function validateXML($cbs, $cbSystems)
	{
		if (!$cbs) {
			throw new BValidateException('123');
		}
		if (!$cbSystems) {
			throw new BValidateException('456');
		}
		return true;
	}
	
	public function getFormattedString($key, $arguments)
	{
		return BI18nMessage::getFormattedMessage($key, $arguments);
	}
	
	public function getDateString()
	{
		return BI18nMessage::getDateString();
	}
	
	public function formatCommonBean($cb, $columnName) 
	{
		return BI18nMessage::formatCommonBean($cb, $columnName);
	}
	
	protected function parseCtrlXml($strXML)
	{
		try {
			return BXmlTool::getRptCtrlXmlStr($strXML);
		} catch (BValidateException $e) {
			throw new BValidateException($e.getMessage());
		}
	}
	
	protected function parseDataXml($strXML) 
	{
		try {
			return BXmlTool::getDataFromXmlStr($strXML);
		} catch (BValidateException $e) {
			throw new BValidateException($e.getMessage());
		}
	}
	
	protected function parseDataXmlCDATA($strXML) 
	{
		try {
			return BXmlTool::getDataFromXmlStrCDATA($strXML);
		} catch (BValidateException $e) {
			throw new BValidateException($e.getMessage());
		}
	}
	
	protected function parseFltXml($strXML) 
	{
		try {
			return BXmlTool::getRptFltXmlStr($strXML);
		} catch (BValidateException $e) {
			throw new BValidateException($e.getMessage());
		}
	}
	
	protected function parseFltXmlMore($strXML) 
	{
		try {
			return BXmlTool::getRptFltXmlStrMore($strXML);
		} catch (BValidateException $e) {
			throw new BValidateException($e.getMessage());
		}
	}
}